package me.heizi.springboot.students.entities

import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import me.heizi.springboot.students.model.UserType


@TableName("users")
data class User(
    @TableId
    val id :Int? = null,
    @TableField("display_name")
    override val username:String,
    @TableField("name")
    val realName:String,
    override val password:String,
    val phone:String,
    val remark:String?,
    private val typeId:Int,
    val classId:Int,
):UserDetails {
    val ROLE get() = UserType.all
        .filter {
            it.id == typeId
        }
    val type get() = UserType.all.find { it.id <= typeId }!!
}

interface UserDetails {
    val password:String
    val username:String
}